<template>
  <view class="content">
    <button type="primary" @click="upimg()">上传图片</button>
    <view v-for="(item, index) in imgArray">
      <image :src="item" @click="previewImg(index)"></image>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      imgArray: [],
    };
  },
  onLoad() {},
  methods: {
    upimg() {
      uni.chooseImage({
        //图片上传
        count: 5,
        success: (res) => {
          this.imgArray = res.tempFilePaths;
        },
      });
    },
    previewImg(index) {
      uni.previewImage({
        //图片预览
        current: index,//设置要放大预览的图片对象
        urls: this.imgArray,
        loop: true,//开启循环播放
      });
    },
  },
};
</script>

<style>
</style>
